<template>
  <el-table :data="tableData" style="width: 100%" height="250" stripe border>
    <!-- 序号 -->
    <el-table-column prop="index" label="序号" width="80" align="center" />

    <!-- 表名称 -->
    <el-table-column prop="tableName" label="表名称" width="150" align="center" />

    <!-- 字段 -->
    <el-table-column prop="field" label="字段" width="120" align="center" />

    <!-- 别名 -->
    <el-table-column prop="alias" label="别名" width="120" align="center" />

    <!-- 标题 -->
    <el-table-column prop="title" label="标题" width="150" align="center" />

    <!-- 字段类型 -->
    <el-table-column prop="fieldType" label="字段类型" width="120" align="center" />

    <!-- 是否主键 -->
    <el-table-column prop="isPrimaryKey" label="是否主键" width="100" align="center">
      <template #default="{ row }">
        <el-tag :type="row.isPrimaryKey === '是' ? 'success' : 'info'">
          {{ row.isPrimaryKey }}
        </el-tag>
      </template>
    </el-table-column>

    <!-- 数据类型 -->
    <el-table-column prop="dataType" label="数据类型" width="120" align="center" />

    <!-- 长度 -->
    <el-table-column prop="length" label="长度" width="80" align="center" />

    <!-- 精度 -->
    <el-table-column prop="precision" label="精度" width="80" align="center" />
  </el-table>
</template>

<script lang="ts" setup>
// 静态表格数据
const tableData = [
  {
    index: 1,
    tableName: "用户表",
    field: "user_id",
    alias: "用户ID",
    title: "用户唯一标识",
    fieldType: "数值型",
    isPrimaryKey: "是",
    dataType: "bigint",
    length: 20,
    precision: 0,
  },
  {
    index: 2,
    tableName: "用户表",
    field: "username",
    alias: "用户名",
    title: "用户登录名称",
    fieldType: "字符型",
    isPrimaryKey: "否",
    dataType: "varchar",
    length: 50,
    precision: 0,
  },
];
</script>

<style scoped lang="scss">
.el-table {
  :deep(.el-table__header) {
    th {
      font-weight: bold;
      color: var(--el-text-color-primary);
      background-color: var(--el-fill-color-light);
    }
  }

  :deep(.el-table__body) {
    td {
      font-size: 14px;
      color: var(--el-text-color-regular);
    }
  }
}
</style>
